Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tip on YAML anchors to docs on dataset layers #2181

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

yury-fedotov
Copy link
Contributor

@yury-fedotov yury-fedotov commented Nov 8, 2024

Description

Closes #2127

Checklist

  • Test if docs render as expected
  • Confirm that content matches expectations

@yury-fedotov yury-fedotov changed the title Give YAML anchors example in docs Add a tip on YAML anchors to docs on dataset layers Nov 8, 2024
layer: raw
can be avoided by leveraging YAML's native syntax for anchors and aliases.
See [this example from the Kedro docs](https://docs.kedro.org/en/stable/data/data_catalog_yaml_examples.html#load-multiple-datasets-with-similar-configuration-using-yaml-anchors).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that those are the docs of a separate project - I assume there's no way to link it other than through static URL?

@yury-fedotov
Copy link
Contributor Author

yury-fedotov commented Nov 8, 2024

Rendered docs: https://kedro--2181.org.readthedocs.build/projects/kedro-viz/en/2181/kedro-viz_visualisation.html#visualise-layers

image

We can't have yaml block nested inside RST note or tip block, so I decided to do just yaml instead. Because without it, RST format compresses those three lines into one: metadata: kedro-viz: layer: raw which is misleading.

@rashidakanchwala
Copy link
Contributor

thanks @yury-fedotov for this, will review this today, and fix the linting issues !

metadata:
kedro-viz:
layer: raw
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also show the example here that you gave in the original issue on how to use it. thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_raw_layer: &raw_layer
  metadata:
    kedro-viz:
      layer: 01_raw

And then reuse it like this:

companies:
  type: pandas.CSVDataset
  filepath: data/01_raw/companies.csv
  <<: *raw_layer

reviews:
  type: pandas.CSVDataset
  filepath: data/01_raw/reviews.csv
  <<: *raw_layer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rashidakanchwala yeah let me add this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yury-fedotov
Copy link
Contributor Author

Copy link
Contributor

@rashidakanchwala rashidakanchwala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. thanks again @yury-fedotov , once we have another approval I will merge this on your behalf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document how to leverage YAML anchors & aliases to avoid copy-pasting properties in catalog
2 participants